#pragma once
#include "util.h"
#include "GameObject.h"


class SimpleMesh : public GameObject
{
	public:
		SimpleMesh(void);
		~SimpleMesh(void);
		SimpleMesh(int numRows, int numCols, float dx, float dz);
		virtual int render(int time);

		int generateRandomSurface(int numRows, int numCols, float dx, float dz);
		int generateFlatSurface(int numRows, int numCols, float dx, float dz);
		int createGraphicsBuffers(void);
		int createVtxDescription(void);
		int setCentrePosition(D3DXVECTOR3 centrePos);

		void setMaterial(float r, float g, float b);

	public:
		struct DefaultVertex	*vertices;	// holds the vertices geometry
		long					*indices;	// holds the topolcoy (indices) of the geometry
		int						nVertices;
		int						nQuads;
		int						nTriangles;
		float cellsize_x;	// cell dimension along x axis
		float cellsize_z;	// cell dimension along z axis
		bool bShowWireframe;
		D3DMATERIAL9			material;
		LPDIRECT3DTEXTURE9		texture;
		
		static IDirect3DVertexDeclaration9* meshDecl;

		int nRows;
		int nCols;
		int setScale(float scaleX, float scaleY, float scaleZ);
};
